﻿@inject IDataCacheService _dataCacheService

@if (Model.Items.Skip((Model.CurrentPage - 1) * Model.MaxCount).Take(Model.MaxCount).Any())
{
    @foreach (var item in Model.Items.Skip((Model.CurrentPage - 1) * Model.MaxCount).Take(Model.MaxCount))
    {
            <CommentPartTip Model="item" IsChild="false" OnRefresh="OnRefrsh" CanDeleted="CanDeleted"></CommentPartTip>
    }

    @if (Model.TotalPages > 1)
    {
        <CnGalWebSite.Components.Paginations.MasaPagination Value="@Model.CurrentPage" Length="@Model.TotalPages" ValueChanged="OnPageClick" />
    }

}



@code {
    [Parameter]
    public CommentCacheModel Model { get; set; }
    [Parameter]
    public bool CanDeleted { get; set; }
    [Parameter]
    public EventCallback OnRefrsh { get; set; }

    private void OnPageClick(int pageIndex)
    {
        Model.CurrentPage = pageIndex;
        StateHasChanged();

    }

    public void PageToEnd()
    {
        Model.CurrentPage = Model.TotalPages;
        StateHasChanged();

    }
}
